package org.budo.mongo.jdbc.driver.parser;

import org.budo.mongo.jdbc.driver.BudoMongoJdbcResultSetMetaData;

/**
 * @author lmw
 */
public class StatementParserUtil {
    public static final String JDBC_PARAMETER_PREFIX = "${JDBC_PARAMETER[";

    public static final int JDBC_PARAMETER_PREFIX_LENGTH = JDBC_PARAMETER_PREFIX.length();

    public static final String JDBC_PARAMETER_SUFFIX = "]}";

    public static final String MATCH = "$match";

    public static final String GROUP = "$group";

    public static final String SET = "$set";

    public static final String NOT = "$not";

    public static final String REGEX = "$regex";

    public static BudoMongoJdbcResultSetMetaData resultSetMetaData(String[] columnNames, int columnType, Class<?> columnClass) {
        String[] columnLabels = new String[columnNames.length];
        int[] columnTypes = new int[columnNames.length];
        String[] columnClassNames = new String[columnNames.length];

        for (int i = 0; i < columnNames.length; i++) {
            columnLabels[i] = columnNames[i];
            columnTypes[i] = columnType;
            columnClassNames[i] = columnClass.getName();
        }

        BudoMongoJdbcResultSetMetaData resultSetMetaData = new BudoMongoJdbcResultSetMetaData();
        resultSetMetaData.columnNames(columnNames);
        resultSetMetaData.columnLabels(columnLabels);
        resultSetMetaData.columnTypes(columnTypes);
        resultSetMetaData.columnClassNames(columnClassNames);
        return resultSetMetaData;
    }
}